package com.java1412.order.controller;

import com.java1412.entity.Goods;
import com.java1412.order.service.GoodsService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * 商品订单信息
 *
 * @author java1412
 * @since 2023-07-21 16:30:05
 */
@RestController
@RequestMapping("/api/v1/goods_order")
public class OrderController {
//    @Resource
//    private RestTemplate restTemplate;
//
//    @RequestMapping("/getGoods")
//    public Object save(int goodsId) {
//        // Goods goods = restTemplate.getForObject("http://localhost:6001/api/v1/goods/findByGoodsId?goodsId=" + goodsId, Goods.class);
//        Goods goods = restTemplate.getForObject("http://mall-goods/api/v1/goods/findByGoodsId?goodsId=" + goodsId, Goods.class);
//        return goods;
//    }

    @Resource
    private GoodsService goodsService;

    @RequestMapping(value = "/getGoodsByFeign")
    public Object getGoodsByFeign(int goodsId) {
        Object obj = goodsService.findByGoodsId(goodsId);
        return obj;
    }

    @RequestMapping("getClusterName")
    public Object findClusterName() {
        for (int i = 0; i < 10; i++) {
            String clusterName = goodsService.findClusterName();
            System.out.println(clusterName);
        }
        return "执行结束";
    }
}
